<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0"><title>Redis--基本语句 | Celts</title><meta name="author" content="PaulGeorge"><meta name="copyright" content="PaulGeorge"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta property="og:type" content="article">
<meta property="og:title" content="Redis--基本语句">
<meta property="og:url" content="https://curry3035.gitee.io/posts/18405/index.html">
<meta property="og:site_name" content="Celts">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://curry3035.gitee.io/img/avatar.jpg">
<meta property="article:published_time" content="2021-05-21T15:29:58.000Z">
<meta property="article:modified_time" content="2022-05-26T18:17:32.054Z">
<meta property="article:author" content="PaulGeorge">
<meta property="article:tag" content="redis">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://curry3035.gitee.io/img/avatar.jpg"><link rel="shortcut icon" href="/img/ic.ico"><link rel="canonical" href="https://curry3035.gitee.io/posts/18405/index.html"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/',
  algolia: undefined,
  localSearch: {"path":"/search.xml","preload":false,"languages":{"hits_empty":"找不到您查询的内容：${query}"}},
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":false,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: true,
    post: true
  },
  runtime: '天',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: {"limitCount":50,"languages":{"author":"作者: PaulGeorge","link":"链接: ","source":"来源: Celts","info":"著作权归作者所有。商业转载请联系作者获得授权，非商业转载请注明出处。"}},
  lightbox: 'fancybox',
  Snackbar: {"chs_to_cht":"你已切换为繁体","cht_to_chs":"你已切换为简体","day_to_night":"你已切换为深色模式","night_to_day":"你已切换为浅色模式","bgLight":"#49b1f5","bgDark":"#1f1f1f","position":"top-right"},
  source: {
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isAnchor: false,
  percent: {
    toc: true,
    rightside: false,
  }
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: 'Redis--基本语句',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2022-05-27 02:17:32'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
    win.getCSS = (url,id = false) => new Promise((resolve, reject) => {
      const link = document.createElement('link')
      link.rel = 'stylesheet'
      link.href = url
      if (id) link.id = id
      link.onerror = reject
      link.onload = link.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        link.onload = link.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(link)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const detectApple = () => {
      if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><link rel="stylesheet" href="/css/background.css"><link rel="stylesheet" href="/css/my.css"><meta name="generator" content="Hexo 5.4.2"></head><body><div id="web_bg"></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="/img/avatar.jpg" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="sidebar-site-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">97</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">64</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">25</div></a></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fa fa-archive"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fa fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fa fa-folder-open"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/photos/"><i class="fa-fw fa fa-camera-retro"></i><span> 图库</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('https://gcore.jsdelivr.net/gh/PaulGeorge123/cloudimg@img/mig2023/background05.jpg')"><nav id="nav"><span id="blog-info"><a href="/" title="Celts"><span class="site-name">Celts</span></a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search" href="javascript:void(0);"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fa fa-archive"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fa fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fa fa-folder-open"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/photos/"><i class="fa-fw fa fa-camera-retro"></i><span> 图库</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div><div id="toggle-menu"><a class="site-page" href="javascript:void(0);"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">Redis--基本语句</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2021-05-21T15:29:58.000Z" title="发表于 2021-05-21 23:29:58">2021-05-21</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2022-05-26T18:17:32.054Z" title="更新于 2022-05-27 02:17:32">2022-05-27</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/%E6%95%B0%E6%8D%AE%E5%BA%93/">数据库</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-wordcount"><i class="far fa-file-word fa-fw post-meta-icon"></i><span class="post-meta-label">字数总计:</span><span class="word-count">1.6k</span><span class="post-meta-separator">|</span><i class="far fa-clock fa-fw post-meta-icon"></i><span class="post-meta-label">阅读时长:</span><span>6分钟</span></span><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="Redis--基本语句"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"><i class="fa-solid fa-spinner fa-spin"></i></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><img src="https://gcore.jsdelivr.net/gh/PaulGeorge123/cloudimg@master/img/all/Redis-Logo.wine.png" style="zoom: 18%;" />

<span id="more"></span>



<h4 id="key–操作数据库"><a href="#key–操作数据库" class="headerlink" title="key–操作数据库"></a>key–操作数据库</h4><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ 插入数据/更新key的值 <span class="built_in">set</span> key_name value </span><br><span class="line"></span><br><span class="line">$ 查询数据 get key_name</span><br><span class="line"></span><br><span class="line">$ 删除键值 del key_name </span><br><span class="line"></span><br><span class="line">$ 验证键是否存在 exists key_name</span><br><span class="line"></span><br><span class="line">$ 返回所有 key  keys *       </span><br><span class="line"></span><br><span class="line">$ 返回所有 xxx开头的 key  keys xxx*</span><br><span class="line"></span><br><span class="line">$ 设置一个 key 的过期时间(单位:秒) expire key_name 10</span><br><span class="line"></span><br><span class="line">$ 移除给定 key 的过期时间 persist key_name </span><br><span class="line"></span><br><span class="line">$ 选择数据库[0..15] select index</span><br><span class="line"></span><br><span class="line">$ 将当前数据库中的 key 转移到其它数据库中 move key_name 1 </span><br><span class="line"></span><br><span class="line">$ 返回值的类型 <span class="built_in">type</span> key_name</span><br><span class="line"></span><br><span class="line">$ 更新key的值返回原来的值 getset key_name value</span><br><span class="line"></span><br><span class="line">$ 测试连接是否存活 ping</span><br><span class="line"></span><br><span class="line">$ 返回当前数据库中 key 的数目 dbsize</span><br><span class="line"></span><br><span class="line">$ 监视--实时转储收到的请求 monitor</span><br><span class="line"></span><br><span class="line">$ 删除当前选择数据库中的所有 key flushdb</span><br><span class="line"></span><br><span class="line">$ 删除所有数据库中的所有 key flushall</span><br></pre></td></tr></table></figure>

<hr>
<h4 id="Redis数据类型-string"><a href="#Redis数据类型-string" class="headerlink" title="Redis数据类型(string)"></a>Redis数据类型(string)</h4><ul>
<li><p>string 是最简单的类型 ，一个 key 对应一个value</p>
</li>
<li><p>redis 的 string 可以包含任何数据， 比如 jpg 图片或者序列化的对象，从内部实现来看其实 string 可以看作 byte 数组，最大上限是 1G 字节。</p>
</li>
</ul>
<figure class="highlight bash"><table><tr><td class="code"><pre><span class="line"><span class="built_in">set</span>:插入数据/更新key的值 <span class="built_in">set</span> name dhee</span><br><span class="line"></span><br><span class="line">get:查询数据 get key_name</span><br><span class="line"></span><br><span class="line">mset:一次设置多个 key 的值 mset key1 dhc key2 jhc</span><br><span class="line"></span><br><span class="line">mget :一次获取多个 key 的值 mget key1 key2 key3</span><br><span class="line"></span><br><span class="line">setnx:如果 key 已经存在，返回 0 ,setnx name dhee</span><br><span class="line"></span><br><span class="line">setex:指定此键值对应的有效期,时间单位为秒 ,setex name 120 dhee</span><br><span class="line"></span><br><span class="line">setrange:设置指定 key 的 value 值的子字符串 ，从指定的位置开始替换字符 ,setrange name 3 @dhc.com</span><br><span class="line"></span><br><span class="line">getrange:获取指定 key 的 value 值的子字符串 getrange name 0 6</span><br><span class="line"></span><br><span class="line">** expire:设置key失效时间 expire key_name 3</span><br><span class="line"></span><br><span class="line">incr keyname 将键存储的值加1</span><br><span class="line"></span><br><span class="line">decr kename 将键存储的是减1</span><br><span class="line"></span><br><span class="line">incrby keyname amount 将键存储的值加上整数amount</span><br><span class="line"></span><br><span class="line">decrby keyname amount 将键存储的值减去整数amount</span><br><span class="line"></span><br><span class="line">incrbyfloat keyname amount 将键存储的值加上浮点数amount</span><br></pre></td></tr></table></figure>

<hr>
<h4 id="Redis-哈希-Hash"><a href="#Redis-哈希-Hash" class="headerlink" title="Redis 哈希(Hash)"></a>Redis 哈希(Hash)</h4><ul>
<li><p>一个 string 类型的 field（字段） 和 value（值） 的映射表，hash 特别适合用于存储对象。</p>
</li>
<li><p>Redis 中每个 hash 可以存储 232 - 1 键值对（40多亿）。</p>
</li>
</ul>
<figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">hset :设置 <span class="built_in">hash</span> field 为指定值,hset myhash name dhee</span><br><span class="line"></span><br><span class="line">hget :获取指定的 <span class="built_in">hash</span> field,hget myhash name</span><br><span class="line"></span><br><span class="line">** hmset:同时设置 <span class="built_in">hash</span> 的多个 field,hmset myhash name dhee age 20</span><br><span class="line"></span><br><span class="line">** hmget :获取全部指定的 <span class="built_in">hash</span> filed,hmget myhash name age password</span><br><span class="line"></span><br><span class="line">** hlen :返回指定 <span class="built_in">hash</span> 的 field 数量,hlen myhash</span><br><span class="line"></span><br><span class="line">hdel :删除一个或多个哈希表字段,hdel myhash age</span><br><span class="line"></span><br><span class="line">hkeys:返回 <span class="built_in">hash</span> 的所有 field,hkeys myhash</span><br><span class="line"></span><br><span class="line">hvals :返回 <span class="built_in">hash</span> 的所有 value:hvals myhash</span><br><span class="line"></span><br><span class="line">hgetall :获取某个 <span class="built_in">hash</span> 中全部的 filed及value,hgetall myhash</span><br></pre></td></tr></table></figure>

<hr>
<h4 id="Redis-列表-List"><a href="#Redis-列表-List" class="headerlink" title="Redis 列表(List)"></a>Redis 列表(List)</h4><ul>
<li><p>简单的字符串列表，按照插入顺序排序。你可以添加一个元素到列表的头部（左边）或者尾部（右边）</p>
</li>
<li><p>一个列表最多可以包含 232 - 1 个元素 (4294967295, 每个列表超过40亿个元素)。</p>
</li>
</ul>
<figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">lpush:在 key 对应 list 的头部添加字符串元素 ,lpush mylist world lpush mylist hello </span><br><span class="line"></span><br><span class="line">lrange: lrange mylist 0 1</span><br><span class="line"></span><br><span class="line">** rpush :在 key 对应 list 的尾部添加字符串元素 , rpush mylist world rpush mylist hello </span><br><span class="line"></span><br><span class="line">** linsert :在 key 对应 list 的特定位置前或后添加字符串 ,linsert mylist before world dhee</span><br><span class="line"></span><br><span class="line">** lset :设置 list 中指定下标的元素值(下标从 0 开始) ,lset mylist 0 dhc</span><br><span class="line"></span><br><span class="line">`lrem` :从 key 对应 list 中删除 count 个和 value 相同的元素,lrem mylist 2 hello</span><br><span class="line"></span><br><span class="line">** ltrim :保留指定 key 的值范围内的数据, ltrim mylist 1 3</span><br><span class="line"></span><br><span class="line">lpop :从 list 的头部删除元素，并返回删除元素, lpop mylist</span><br><span class="line"></span><br><span class="line">** rpop :从 list 的尾部删除元素，并返回删除元素, rpop mylist</span><br><span class="line"></span><br><span class="line">** lindex :返回名称为 key 的 list 中 index 位置的元素 ,lindex mylist 0</span><br><span class="line"></span><br><span class="line">** llen :返回 key 对应 list 的长度 ,llen mylist</span><br></pre></td></tr></table></figure>

<hr>
<h4 id="Redis-集合-Set"><a href="#Redis-集合-Set" class="headerlink" title="Redis 集合(Set)"></a>Redis 集合(Set)</h4><ul>
<li><p>Redis 的 Set 是 String 类型的无序集合。集合成员是唯一的，这就意味着集合中不能出现重复的数据。</p>
</li>
<li><p>Redis 中集合是通过哈希表实现的，所以添加，删除，查找的复杂度都是 O(1)。</p>
</li>
<li><p>集合中最大的成员数为 232 - 1 (4294967295, 每个集合可存储40多亿个成员)。</p>
</li>
</ul>
<figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">`sadd` ： sadd myset hello</span><br><span class="line"></span><br><span class="line">`smembers` ：查看 myset 中的所有元素 , smembers myset</span><br><span class="line"></span><br><span class="line">`srem` ：删除名称为 key 的 <span class="built_in">set</span> 中的元素 member, srem myset hello</span><br><span class="line"></span><br><span class="line">spop ：随机删除名称为 key 的 se t 中一个元素,spop myset</span><br><span class="line"></span><br><span class="line">sdiff:返回第一个 <span class="built_in">set</span>集合与第二个 <span class="built_in">set</span>集合的差集,sdiff myset2 myset1</span><br><span class="line"></span><br><span class="line">sdiffstore :返回第一个 <span class="built_in">set</span>集合与第二个 <span class="built_in">set</span>集合的差集 ，并将结果存为另一个 <span class="built_in">set</span>, sdiffstore</span><br><span class="line"></span><br><span class="line">myset3 myset2 myset1</span><br><span class="line"></span><br><span class="line">sinter:返回所有给定 key 的交集 ,sinter myset1 myset2</span><br><span class="line"></span><br><span class="line">sinterstore :返回所有给定 key 的交集，并将结果存为另一个 key ,sinterstore myset4 myset2 </span><br><span class="line"></span><br><span class="line">myset1</span><br><span class="line"></span><br><span class="line">`sunion`:返回所有给定 key 的并集 ,sunion myset2 myset1</span><br><span class="line"></span><br><span class="line">sunionstore :返回所有给定 key 的并集，并将结果存为另一个key </span><br><span class="line"></span><br><span class="line">sunionstore myset5 myset2 myset1</span><br><span class="line"></span><br><span class="line">`scard`:返回名称为 key 的 <span class="built_in">set</span> 的元素个数 ,scard myset2</span><br></pre></td></tr></table></figure>
<hr>
<h4 id="Redis-有序集合-sorted-set"><a href="#Redis-有序集合-sorted-set" class="headerlink" title="Redis 有序集合(sorted set)"></a>Redis 有序集合(sorted set)</h4><ul>
<li><p>Redis 有序集合和集合一样也是 string 类型元素的集合,且不允许重复的成员。</p>
</li>
<li><p>不同的是每个元素都会关联一个 double 类型的分数。redis 正是通过分数来为集合中的成员进行从小到大的排序。</p>
</li>
<li><p>有序集合的成员是唯一的,但分数(score)却可以重复。</p>
</li>
<li><p>集合是通过哈希表实现的，所以添加，删除，查找的复杂度都是 O(1)。 集合中最大的成员数为 232 - 1 (4294967295, 每个集合可存储40多亿个成员)。</p>
</li>
</ul>
<figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">`zadd`：向名称为 key 的 zset 中添加元素 member， score 用于设定分数。如果该元素已经存在，则根据</span><br><span class="line"></span><br><span class="line">`score` 更新该元素的分数。zadd key score member,zrange myzset 0 -1 withscores</span><br><span class="line"></span><br><span class="line">`zrem` :删除名称为 key 的 zset 中的元素 member ,zrem myzset two</span><br><span class="line"></span><br><span class="line">`zincrby`：给成员增加指定分数 zincrby myzset 1 one</span><br><span class="line"></span><br><span class="line">`zrank` ：返回zset 中名称为 key 的 member 元素的排名(按 score 从小到大排序)即下标 zrank myzset two</span><br><span class="line"></span><br><span class="line">`zrevrank`：返回zset 中名称为 key 的 member 元素的排名(按 score 从大到小排序)即下标 zrevrank myzset two</span><br><span class="line"></span><br><span class="line">`zrevrange` ：按 score 从大到小排序，再取出全部元素 ,zrevrange myzset 0 -1 withscores</span><br><span class="line"></span><br><span class="line">`zrangebyscore` ：返回集合中 score 在给定区间的元素,zrangebyscore myzset 2 3 withscores</span><br><span class="line"></span><br><span class="line">`zcount` ：返回集合中 score 在给定区间的数量 ,zcount myzset 2 3</span><br><span class="line"></span><br><span class="line">`zcard` ：返回集合中元素个数 zcard myzset (key 的个数)</span><br><span class="line"></span><br><span class="line">`zscore` ：返回给定元素对应的 score ,zscore myzset two (key 的 score 数量)</span><br><span class="line"></span><br><span class="line">zremrangebyrank ：删除集合中排名在给定区间的元素 ,zremrangebyrank myzset 3 3</span><br><span class="line"></span><br><span class="line">zremrangebyscore ：删除集合中 score 在给定区间的元素,zremrangebyscore myzset 1 2</span><br><span class="line"></span><br></pre></td></tr></table></figure></article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="https://curry3035.gitee.io">PaulGeorge</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="https://curry3035.gitee.io/posts/18405/">https://curry3035.gitee.io/posts/18405/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="https://curry3035.gitee.io" target="_blank">Celts</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/redis/">redis</a></div><div class="post_share"><div class="social-share" data-image="/img/avatar.jpg" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/posts/45686/" title="面试题（Java基础）"><div class="cover" style="background: var(--default-bg-color)"></div><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">面试题（Java基础）</div></div></a></div><div class="next-post pull-right"><a href="/posts/46617/" title="MongoDB概念"><div class="cover" style="background: var(--default-bg-color)"></div><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">MongoDB概念</div></div></a></div></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span>相关推荐</span></div><div class="relatedPosts-list"><div><a href="/posts/32436/" title="学习--Redis事务、锁机制"><div class="cover" style="background: var(--default-bg-color)"></div><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-09-09</div><div class="title">学习--Redis事务、锁机制</div></div></a></div><div><a href="/posts/26019/" title="实践一下--Redis集群"><div class="cover" style="background: var(--default-bg-color)"></div><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-09-08</div><div class="title">实践一下--Redis集群</div></div></a></div><div><a href="/posts/60188/" title="每日一面--Redis和MySQL数据一致性问题"><div class="cover" style="background: var(--default-bg-color)"></div><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-07-22</div><div class="title">每日一面--Redis和MySQL数据一致性问题</div></div></a></div><div><a href="/posts/48441/" title="每日一面--Redis 五种数据结构详解"><div class="cover" style="background: var(--default-bg-color)"></div><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-07-21</div><div class="title">每日一面--Redis 五种数据结构详解</div></div></a></div><div><a href="/posts/11389/" title="每日一面--布隆过滤器"><div class="cover" style="background: var(--default-bg-color)"></div><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-07-16</div><div class="title">每日一面--布隆过滤器</div></div></a></div><div><a href="/posts/3169/" title="每日一面--Redis"><div class="cover" style="background: var(--default-bg-color)"></div><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-07-15</div><div class="title">每日一面--Redis</div></div></a></div></div></div></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src="/img/avatar.jpg" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">PaulGeorge</div><div class="author-info__description">很多事情就像是旅行一样，当你决定要出发的时候，最困难的那部分其实就已经完成了</div></div><div class="card-info-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">97</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">64</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">25</div></a></div><a id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/PaulGeorge123"><i class="fab fa-github"></i><span>GitHub URL</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="https://github.com/PaulGeorge123" target="_blank" title="Github"><i class="fab fa-github"></i></a></div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content is-expand"><ol class="toc"><li class="toc-item toc-level-4"><a class="toc-link" href="#key%E2%80%93%E6%93%8D%E4%BD%9C%E6%95%B0%E6%8D%AE%E5%BA%93"><span class="toc-number">1.</span> <span class="toc-text">key–操作数据库</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#Redis%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B-string"><span class="toc-number">2.</span> <span class="toc-text">Redis数据类型(string)</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#Redis-%E5%93%88%E5%B8%8C-Hash"><span class="toc-number">3.</span> <span class="toc-text">Redis 哈希(Hash)</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#Redis-%E5%88%97%E8%A1%A8-List"><span class="toc-number">4.</span> <span class="toc-text">Redis 列表(List)</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#Redis-%E9%9B%86%E5%90%88-Set"><span class="toc-number">5.</span> <span class="toc-text">Redis 集合(Set)</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#Redis-%E6%9C%89%E5%BA%8F%E9%9B%86%E5%90%88-sorted-set"><span class="toc-number">6.</span> <span class="toc-text">Redis 有序集合(sorted set)</span></a></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/posts/47231/" title="POI读取Excel问题">POI读取Excel问题</a><time datetime="2023-04-11T01:00:00.000Z" title="发表于 2023-04-11 09:00:00">2023-04-11</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/posts/8422/" title="Excel大文件的上传">Excel大文件的上传</a><time datetime="2023-04-10T01:00:00.000Z" title="发表于 2023-04-10 09:00:00">2023-04-10</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/posts/55119/" title="每日一面--Files工具类">每日一面--Files工具类</a><time datetime="2023-01-01T01:00:00.000Z" title="发表于 2023-01-01 09:00:00">2023-01-01</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/posts/34600/" title="面试一下--JUC入门">面试一下--JUC入门</a><time datetime="2022-09-10T01:00:00.000Z" title="发表于 2022-09-10 09:00:00">2022-09-10</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/posts/16284/" title="每日一面--字符流和字节流">每日一面--字符流和字节流</a><time datetime="2022-07-01T01:00:00.000Z" title="发表于 2022-07-01 09:00:00">2022-07-01</time></div></div></div></div></div></div></main><footer id="footer" style="background-image: url('https://gcore.jsdelivr.net/gh/PaulGeorge123/cloudimg@img/mig2023/background05.jpg')"><div id="footer-wrap"><div class="copyright">&copy;2020 - 2023 By PaulGeorge</div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><span class="scroll-percent"></span><i class="fas fa-arrow-up"></i></button></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.umd.min.js"></script><script src="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.js"></script><div class="js-pjax"></div><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div><div id="local-search"><div class="search-dialog"><nav class="search-nav"><span class="search-dialog-title">搜索</span><span id="loading-status"></span><button class="search-close-button"><i class="fas fa-times"></i></button></nav><div class="is-center" id="loading-database"><i class="fas fa-spinner fa-pulse"></i><span>  数据库加载中</span></div><div class="search-wrap"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div><hr/><div id="local-search-results"></div></div></div><div id="search-mask"></div><script src="/js/search/local-search.js"></script></div></body></html>